package com.hp.team.bookstore.model.order;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.hp.team.bookstore.model.catalog.Vendor;

@Entity
@Table(name = "PO_REQUIREMENT")
public class PORequirement implements Comparable<PORequirement> {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID")
	private long id;
	
	@OneToOne
	@JoinColumn(name = "SALES_ORDER_ITEM_ID")
	private SalesOrderItem orderItem;
	
	@OneToOne
	@JoinColumn(name = "VENDOR_ID")
	private Vendor vendor;
	
	@ManyToOne
	@JoinColumn(name="PURCHASE_ORDER_ID")
	private PurchaseOrder purchaseOrder;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public SalesOrderItem getOrderItem() {
		return orderItem;
	}

	public void setOrderItem(SalesOrderItem salesOrderItem) {
		this.orderItem = salesOrderItem;
	}

	public Vendor getVendor() {
		return vendor;
	}

	public void setVendor(Vendor vendor) {
		this.vendor = vendor;
	}

	public PurchaseOrder getPurchaseOrder() {
		return purchaseOrder;
	}

	public void setPurchaseOrder(PurchaseOrder purchaseOrder) {
		this.purchaseOrder = purchaseOrder;
	}

	@Override
	public int compareTo(PORequirement other) {
		return (int) (id - other.id);
	}
}
